package top.superflow.db.api

import top.superflow.verify.Ensure
import top.superflow.verify.Validatable
import top.superflow.exception.RequestUnsupportedException

trait DBConfigurationValidator extends Validatable
                               with Ensure{
  
  def validate(target : Any) : Boolean = {
    notNull(target, "Database configuration should not be null")
    
    target match {
      case t : DBConfiguration =>{
        notNull(t.getUrl, "url in Database configuration should not be null")
        notNull(t.getUsername, "user name in Database configuration should not be null")
        notNull(t.getPassword, "password in Database configuration should not be null")
      }
      case _ =>{
        notSupported(target)
      }
    }
    
    return true;
  }
}